﻿using System.Collections.Generic;
using System.Linq;

namespace Chevron.OrderDetails.Models
{
    public class PhysiciansCatalog : Dictionary<string, PhysicianDto>
    {
        public PhysicianDto GetPhysician(string upin, string name)
        {
            if (string.IsNullOrEmpty(upin))
            {
                upin = @"<ANON>";
            }

            upin = upin.ToUpperInvariant();
            if (!ContainsKey(upin))
            {
                Add(upin, new PhysicianDto {PhysicianUpin = upin, PhysicianName = name});
            }
            return this[upin];
        }

        public List<PhysicianDto> SortByName()
        {
            List<PhysicianDto> values = (from v in Values
                                         orderby v.PhysicianName
                                         select v).ToList();
            return values;
        }
    }
}